<template>
    <div class="home">
        <h1>这是一个用来测试的Home页面{{msg}}</h1>
        <button @click="onClick">按钮(派发数据给子组件test2)</button>
        <hr/>
        <test1/>
        <hr/>
        <test2/>
    </div>
</template>
<script>
import Test1 from '../components/test1'
import Test2 from '../components/test2'
import Emitter from '../mixin/emitter'
export default {
  name: 'home',
  components: {
    Test1,
    Test2
  },
  mixins: [Emitter],
  data() {
    return {
      msg: 123
    }
  },
  methods: {
    onClick() {
      this.broadcast('test2', 'sss', this.msg)
    }
  },
  mounted() {
    this.$on('sss', item => {
      this.msg = item
    })
  }
}
</script>
<style scoped>
.home {
  color: #333;
}
</style>
